const initialState = {  
    isLoggedIn: false,  
    token: null,  
    user: null,
  };  
    
  function authReducer(state = initialState, action: { type: string; payload?: any }) {  
    switch (action.type) {  
      case 'LOGIN_SUCCESS':  
        // console.log("action.payload.user", action.payload.user);
        return {  
          ...state,  
          isLoggedIn: true,  
          token: action.payload.token,  
          user: action.payload.user,
        };  
      case 'LOGOUT':  
        return {  
          ...state,  
          isLoggedIn: false,  
          token: null,  
          user: null,
        };  
      default:  
        return state;  
    }  
  }  
    
  export default authReducer;
  